home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / cert / trk3_eg / fmdrgdrp / opt2 / invent.exe / DBSFORM.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-08-20  |  6.3 KB  |  182 lines

  1. VERSION 2.00
  2. Begin Form DbsForm 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   2235
  5.    ClientLeft      =   2220
  6.    ClientTop       =   2220
  7.    ClientWidth     =   4980
  8.    Height          =   2640
  9.    HelpContextID   =   101
  10.    Icon            =   DBSFORM.FRX:0000
  11.    Left            =   2160
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MDIChild        =   -1  'True
  15.    ScaleHeight     =   2235
  16.    ScaleWidth      =   4980
  17.    Top             =   1875
  18.    Width           =   5100
  19.    Begin CommandButton LoadRowCmd 
  20.       Caption         =   "LoadRowCmd"
  21.       Height          =   375
  22.       Left            =   120
  23.       TabIndex        =   1
  24.       Top             =   1800
  25.       Visible         =   0   'False
  26.       Width           =   1455
  27.    End
  28.    Begin TgDemo DbsTable 
  29.       BackColor       =   &H00C0C0C0&
  30.       BorderStyle     =   0  'None
  31.       Configurable    =   0   'False
  32.       DragIcon        =   DBSFORM.FRX:0302
  33.       Editable        =   0   'False
  34.       EditBackColor   =   &H8000000D&
  35.       EditForeColor   =   &H8000000E&
  36.       FetchMode       =   0  'By cell
  37.       FontBold        =   0   'False
  38.       FontItalic      =   0   'False
  39.       FontName        =   "MS Sans Serif"
  40.       FontSize        =   8.25
  41.       FontStrikethru  =   0   'False
  42.       FontUnderline   =   0   'False
  43.       HeadBackColor   =   &H80000002&
  44.       HeadForeColor   =   &H80000009&
  45.       Headings        =   -1  'True
  46.       Height          =   1695
  47.       HorzColor       =   &H00808080&
  48.       HorzLines       =   2  '3D
  49.       InactiveBackColor=   &H00808080&
  50.       InactiveForeColor=   &H00000000&
  51.       Layout          =   DBSFORM.FRX:0604
  52.       Left            =   0
  53.       MarqueeStyle    =   3  'Highlight Row
  54.       SelectedBackColor=   &H00000000&
  55.       SelectedForeColor=   &H00FFFFFF&
  56.       SelectMode      =   0  'Disabled
  57.       TabIndex        =   0
  58.       Top             =   0
  59.       UseBookmarks    =   -1  'True
  60.       VertColor       =   &H00808080&
  61.       VertLines       =   2  '3D
  62.       Width           =   3855
  63.    End
  64. ' Local definitions for dbs form
  65. Dim WidthDelta As Integer
  66. Dim FormIndex As Integer
  67. Dim ourdb As Database
  68. Dim ourDbFile As String
  69. ' Map of each row
  70. Dim rowName() As String
  71. Sub DbsTable_DblClick ()
  72.     DbsOpenCurrentTable FormIndex
  73. End Sub
  74. Sub DbsTable_DragDrop (Source As Control, X As Single, Y As Single)
  75.     valid% = EndDragMode(MASK_NONE)
  76. End Sub
  77. Sub DbsTable_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  78.    valid% = DragValid(Source, MASK_NONE, State)
  79. End Sub
  80. Sub DbsTable_Fetch (Row As Long, Col As Integer, Value As String)
  81.     ' This event is called by the grid whenever it needs
  82.     ' data for a particular cell ... it stores no data
  83.     ' of its own.
  84.     rname$ = rowName(Row)
  85.     Select Case DbsTable.ColumnName(Col)
  86.         Case "Name"
  87.             Value = TnameDisp(rname$)
  88.         Case "Last Updated"
  89.             Value = Format$(ourdb(rname$).LastUpdated)
  90.         Case "Kind"
  91.             Value = TnameTypeDisp(rname$)
  92.     End Select
  93. End Sub
  94. Sub DbsTable_GotFocus ()
  95.     ' Assure that the table menu is visible, and make
  96.     ' a custom help message depending upon whether any
  97.     ' tables are present.
  98.     MDIMain.Table.Visible = True
  99.     MDIMain.TableDelete.Enabled = (DbsTable.Rows <> 0)
  100.     msg$ = "Tables in " + ExtractFile(ourDbFile) + " - "
  101.     If DbsTable.Rows Then
  102.         SetStatus msg$ + "drag or double-click to open; table menu to change"
  103.     Else
  104.         SetStatus msg$ + "table menu to create new tables"
  105.     End If
  106. End Sub
  107. Sub DbsTable_LostFocus ()
  108.     MDIMain.Table.Visible = False
  109. End Sub
  110. Sub DbsTable_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  111.     GridMaybeDrag DbsTable, X, Y
  112. End Sub
  113. Sub DbsTable_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  114.     GridTestDrag DbsTable, Button, X, Y, MASK_TABLE, Utils.DragDisk
  115. End Sub
  116. Sub DbsTable_RowChange ()
  117.     ' element zero of rowName is always "", so if the
  118.     ' list is empty, fiTable is ""
  119.     DbsFormItems(FormIndex).fiTable = rowName(DbsTable.RowIndex)
  120.     If DbsTable.RowIndex = 0 Then    ' no rows
  121.         DbsFormItems(FormIndex).fiTable = ""
  122.         MDIMain.TableDelete.Enabled = False
  123.     Else
  124.         DbsFormItems(FormIndex).fiTable = rowName(DbsTable.RowIndex)
  125.         MDIMain.TableDelete.Enabled = True
  126.     End If
  127. End Sub
  128. Sub Form_Load ()
  129.     ' Remember the difference between the grid width
  130.     ' and our width for resize constraints
  131.     WidthDelta = Me.Width - Me.ScaleWidth
  132.     ' Capture information about our contents, passed to
  133.     ' us from DbsOpen or DbsCreate in DBS.BAS
  134.     FormIndex = FormLastAlloc()
  135.     Me.Tag = FormIndex
  136.     ourDbFile = DbsFormItems(FormIndex).fiFileName
  137.     Set ourdb = OpenDatabase(ourDbFile)
  138.     Set DbsFormDatabase(FormIndex) = ourdb
  139.     DbsTable.Tag = FormIndex
  140.     ' Fill the grid with data
  141.     LoadRows
  142. End Sub
  143. Sub Form_Resize ()
  144.     ' Constrain our width to the design-time grid width
  145.     If Me.WindowState = NORMAL Then
  146.         Me.Width = DbsTable.Width + WidthDelta
  147.         DbsTable.Height = Me.ScaleHeight
  148.     End If
  149. End Sub
  150. Sub Form_Unload (Cancel As Integer)
  151.     ' Close the database when our form is closed.  Other
  152.     ' forms keep it open, so don't worry.
  153.     ourdb.Close
  154.     FormFree DbsFormItems(FormIndex)
  155.     ' Kill the table menu
  156.     MDIMain.Table.Visible = False
  157. End Sub
  158. Sub LoadRowCmd_Click ()
  159.     ' This button is "pressed" by code in other forms
  160.     ' when they know that a table has been added or
  161.     ' deleted.
  162.     LoadRows
  163. End Sub
  164. Sub LoadRows ()
  165.     ' Loop through all the rows in the TableDefs,
  166.     ' pruning out system tables.  Fill the rowName array,
  167.     ' and the grid Fetch event will access each table
  168.     ' definition when it needs it.
  169.     ReDim rowName(ourdb.TableDefs.Count)
  170.     rowcount% = 0
  171.     For i% = 0 To ourdb.TableDefs.Count - 1
  172.         If (ourdb.TableDefs(i%).Attributes And DB_SYSTEMOBJECT) = 0 Then
  173.             rowcount% = rowcount% + 1
  174.             rowName(rowcount%) = ourdb.TableDefs(i%).Name
  175.         End If
  176.     Next i%
  177.     ReDim Preserve rowName(rowcount%)
  178.     DbsTable.Rows = rowcount%
  179.     If rowcount% Then DbsTable.RowIndex = 1
  180.     DbsTable.Refresh
  181. End Sub
  182.